import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] nums = in.nextLine().split(" ");
        Integer[] nums1 = new Integer[nums.length];
        for (int i = 0; i < nums.length; i++) {
            try {
                int num = Integer.valueOf(nums[i]);
                if (num > 9 || num < 0) {
                    System.out.println("Numerical range error");
                    break;
                }
                nums1[i] = num;
            } catch (Exception e) {
                System.out.println("number input error");
                break;
            }
        }
        List<Integer> list = Arrays.asList(nums1);
        Collections.sort(list);
        int j = 3;
        int sum = 0;
        for (int i = list.size() - 1; i >= 0; i--) {
            sum += list.get(i) * (int) Math.pow(10, j);
            j--;
        }
        System.out.print(sum);
        System.out.print(" ");
        j = 3;
        sum = 0;
        for (int i = 0; i < list.size(); i++) {
            sum += list.get(i) * (int) Math.pow(10, j);
            j--;
        }
        System.out.print(sum);
    }
}
